1. Variables

  • Constants are usually defined on a module level and written in all capital letters with underscores separating words, e.g., MAX_OVERFLOW.

  • arguments. Always use self for the first argument to instance methods and use cls for the first argument to class methods (@classmethod).

2. Others

  • Function should be lowercase with words separated by underscores as necessary to improve readability. PS: mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py) to retain backwards compatibility.

  • Exception should use the suffix Error (if the exception actually is an error), such as ZeroDivisionError. The class naming convention applies here because exceptions should be classes.

本文系Spark & Shine原创,转载需注明出处本文最近一次修改时间 2022-03-18 19:04

results matching ""

    No results matching ""